<div class="layui-fluid" id="VIEW-list-table" lay-title="盘点机列表" lig-title="co-mach-title">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header" lig-lang="label-searchTitle">筛选数据</div>
                <div class="layui-card-body">
                    <div class="layui-row layui-col-space10 layui-form">
                        <form class="layui-form" lay-filter="lig-machine-searchform">
                            <div class="layui-row">
                                <div class="layui-inline">
                                    <label class="layui-form-label" lig-lang="pd-customer">客户</label>
                                    <div class="layui-inline">
                                        <select name="customerCode">
                                            <option value=""></option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label" lig-lang="mach-machineXlh">序列号</label>
                                    <div class="layui-inline">
                                        <input type="text" class="layui-input" name="machineXlh"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-row layui-col-space10">
                                        <div class="layui-col-xs6">
                                            <div class="layui-btn layui-btn-sm layui-btn-fluid"
                                                 lay-filter="lig-machine-search" lig-lang="btn-search">查询
                                            </div>
                                        </div>
                                        <div class="layui-col-xs6">
                                            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary" lig-lang="btn-reset">重置</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <div class="layui-btn-container nepadmin-pad-t10 nepadmin-pad-l10">
                        <div class="layui-btn layui-btn-sm" lay-filter="lig-machine-add" lig-lang="btn-addMachine">添加盘点机</div>
                    </div>
                    <table lay-filter="lig-machine-table"></table>
                </div>
            </div>
        </div>
    </div>
    <script type="text/html" id="tpl-row-toolBar">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="lig-modify" lay-filter="lig-machine-modify" lig-lang="btn-modify">修改</a>
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="lig-delete" lay-filter="lig-machine-delete" lig-lang="btn-delete">删除</a>
    </script>
    <script type="text/html" id="tpl-machine-modify">
        <div class="layui-row" style="padding-top: 20px;">
            <div class="layui-col-md8">
                <form class="layui-form" lay-filter="lig-saveform" id="lig-saveform">
                    <input type="hidden" name="machineId" value="{{d.machineId}}"/>
                    <div class="layui-form-item">
                        <label class="layui-form-label ligui-form-item-required" lig-lang="mach-machineXlh">序列号</label>
                        <div class="layui-input-block">
                            <input type="text" name="machineXlh" autocomplete="off" class="layui-input" lay-verify="required"
                                   value='{{d.machineXlh}}'>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label ligui-form-item-required" lig-lang="pd-customer">客户</label>
                        <div class="layui-input-block">
                            <select name="customerCode" lay-data="{{d.customerCode}}" lay-verify="required">
                                <option value=""></option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label ligui-form-item-required" lig-lang="mach-bdsj">绑定时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="bdsj" autocomplete="off" class="layui-input" value='{{d.bdsj}}' lay-verify="required">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" lig-lang="mach-remark">备注</label>
                        <div class="layui-input-block">
                            <input type="text" name="remark" autocomplete="off" class="layui-input"
                                    value='{{d.remark}}'>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="ligui-layer-btn" style="text-align:left;padding:10px 105px;pointer-events:auto;">
                            <a class="ligui-layer-btn0 ligui-save" lay-submit="" lay-filter="lig-save" lig-lang="btn-save">保 存</a>
                            <a class="ligui-layer-btn1 ligui-cancel" lig-lang="btn-cancel">取 消</a>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-col-md4"></div>
        </div>
    </script>
    <script type="text/html" id="tpl-machine-add">
        <div class="layui-row" style="padding-top: 20px;">
            <div class="layui-col-md8">
                <form class="layui-form" lay-filter="lig-saveform" id="lig-machine-addform">
                    <div class="layui-form-item">
                        <label class="layui-form-label ligui-form-item-required" lig-lang="mach-machineXlh">序列号</label>
                        <div class="layui-input-block">
                            <input type="text" name="machineXlh" autocomplete="off" class="layui-input" lay-verify="required"
                                    value=''>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label ligui-form-item-required" lig-lang="pd-customer">客户</label>
                        <div class="layui-input-block">
                            <select name="customerCode" id="customerCode" lay-verify="required">
                                <option value=""></option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label ligui-form-item-required" lig-lang="mach-bdsj">绑定时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="bdsj" autocomplete="off" class="layui-input" value='' lay-verify="required">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" lig-lang="mach-remark">备注</label>
                        <div class="layui-input-block">
                            <input type="text" name="remark" autocomplete="off" class="layui-input"
                                    value=''>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="ligui-layer-btn" style="text-align:left;padding:10px 105px;pointer-events:auto;">
                            <a class="ligui-layer-btn0 ligui-save" lay-submit="add" lay-filter="lig-save" lig-lang="btn-save">保 存</a>
                            <a class="ligui-layer-btn1 ligui-cancel" lig-lang="btn-cancel">取 消</a>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-col-md4"></div>
        </div>
    </script>
</div>
<script>
    layui.use(['admin', 'table', 'form', 'dropdown', 'laytpl', 'laydate', 'jquery', 'lig'], function (admin, table, form, dropdown, laytpl, laydate, $, lig) {
        var _searchForm = '[lay-filter="lig-machine-searchform"]';
        lig.selectCustomerList(_searchForm + '  select[name="customerCode"]');
        form.render();

        lig.table({
            elem: '[lay-filter="lig-machine-table"]',
            url: 'pd/machine/page',
            cols: [[
                {title: '<span lig-lang="label-opt">操作</span>', toolbar: '#tpl-row-toolBar', align: 'left', width: 120, fixed: 'left'},
                {title: '<span lig-lang="mach-machineXlh">盘点机序列号</span>', field: 'machineXlh', minWidth: 120},
                {title: '<span lig-lang="pd-customer">客户</span>', field: 'customerCode', minWidth: 120},
                {title: '<span lig-lang="mach-bdsj">绑定时间</span>', field: 'bdsj', minWidth: 120},
                {title: '<span lig-lang="mach-remark">备注</span>', field: 'remark', minWidth: 250},
            ]]
        }, {
            entity: 'machine',
            primaryField: 'machineId',
            addContent: $('#tpl-machine-add').html(),
            addUrl: 'pd/machine/add',
            addTitle: '<span lig-lang="mach-addMachine">添加盘点机</span>',
            addHeight: 'auto',
            onAddOpened: function () {
                var _saveForm = '[lay-filter="lig-saveform"]';
                lig.selectCustomerList('[lay-filter="lig-saveform"] select[name="customerCode"]');
                laydate.render({
                    elem: _saveForm + ' input[name="bdsj"]',
                    value: lig.getDateNow()
                });
            },

            modifyContent: $('#tpl-machine-modify').html(),
            modifyUrl:
                'pd/machine/modify',
            modifyTitle:
                '<span lig-lang="mach-modifyMachine">修改盘点机</span>',
            modifyHeight:
                'auto',
            onModifyOpened: function () {
                var _saveForm = '[lay-filter="lig-saveform"]';
                lig.selectCustomerList('[lay-filter="lig-saveform"] select[name="customerCode"]');
                laydate.render({
                    elem: _saveForm + ' input[name="bdsj"]'
                });
            },

            removeUrl: 'pd/machine/remove',
            getUrl:'pd/machine/{machineId}'
        });


    })
</script>